public class Bullet extends SpaceOb{
	//Breytur
	private final double Bulletspeed=1;
	private final double Bulletradius=1;
	private final double MaxDistance=1;
	private double DistanceTravelled=0;
	private Circle p;
	//Constructor
	public Bullet(Ship PlayerShip){
		super();
		setPosx(PlayerShip.getPosx());
		setPosy(PlayerShip.getPosy());
		setVelx(Bulletspeed*Math.cos(PlayerShip.getFaceAngle()));
		setVely(Bulletspeed*Math.sin(PlayerShip.getFaceAngle()));
		setAlive(true);
		p = new Circle(this.getPosx(),this.getPosy(),Bulletradius);
		setObShape(p);
	}
	
	public void update(){
		incPosx(getVelx());
		if(getPosx()>1000){incPosx(-2000);}
		if(getPosx()<-1000){incPosx(2000);}
		incPosy(getVely());
		if(getPosy()>1000){incPosy(-2000);}
		if(getPosy()<-1000){incPosy(2000);}
		DistanceTravelled += Math.sqrt(getVelx()*getVelx()+getVely()*getVely());
		if(DistanceTravelled>MaxDistance){
			setAlive(false);
		}
		p = new Circle(this.getPosx(),this.getPosy(),Bulletradius);
		setObShape(p);
	}
	
	public void draw(){
		StdDraw.circle(getPosx(),getPosy(),Bulletradius);
	}
}